#
# Franklin and Hopper
#
CC = CC
MPCC = CC
OPENMP = -fopenmp
# CFLAGS = -O3 -g -pg
CFLAGS = -O3 
# CFLAGS = -Wall -O3 -fsingle-precision-constant
# LDFLAGS = -g -pg
LDFLAGS = 
LIBS = -lm


TARGETS = serial pthreads openmp mpi serial-orig pthreads-orig openmp-orig mpi-orig

all:	$(TARGETS)

serial: serial.o common.o
	$(CC) -o $@ serial.o common.o $(LIBS) $(LDFLAGS)
pthreads: pthreads.o common.o
	$(CC) -o $@ -lpthread pthreads.o common.o $(LIBS)
openmp: openmp.o common.o
	$(CC) -o $@ $(LIBS) $(LDFLAGS) $(OPENMP) openmp.o common.o
mpi: mpi.o common.o
	$(MPCC) -o $@ mpi.o common.o $(LIBS) $(MPILIBS) $(OPENMP) 

serial-orig: serial-orig.o common.o
	$(CC) -o $@ serial-orig.o common.o $(LIBS) $(LDFLAGS)
pthreads-orig: pthreads-orig.o common.o
	$(CC) -o $@ -lpthread pthreads-orig.o common.o $(LIBS)
openmp-orig: openmp-orig.o common.o
	$(CC) -o $@ $(LIBS) $(LDFLAGS) $(OPENMP) openmp-orig.o common.o
mpi-orig: mpi-orig.o common.o
	$(MPCC) -o $@ mpi-orig.o common.o $(LIBS) $(MPILIBS)



openmp.o: openmp.cpp common.h
	$(CC) -c $(OPENMP) $(CFLAGS) openmp.cpp
serial.o: serial.cpp common.h
	$(CC) -c $(CFLAGS) serial.cpp
pthreads.o: pthreads.cpp common.h
	$(CC) -c $(CFLAGS) pthreads.cpp
mpi.o: mpi.cpp common.h
	$(MPCC) -c $(CFLAGS) mpi.cpp
common.o: common.cpp common.h
	$(CC) -c $(CFLAGS) common.cpp

openmp-orig.o: openmp-orig.cpp common.h
	$(CC) -c $(OPENMP) $(CFLAGS) openmp-orig.cpp
serial-orig.o: serial-orig.cpp common.h
	$(CC) -c $(CFLAGS) serial-orig.cpp
pthreads-orig.o: pthreads-orig.cpp common.h
	$(CC) -c $(CFLAGS) pthreads-orig.cpp
mpi-orig.o: mpi-orig.cpp common.h
	$(MPCC) -c $(CFLAGS) mpi-orig.cpp

clean:
	rm -f *.o $(TARGETS)
